package com.gaozhen.demo;

import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
        //数字加密（也是解密程序）
        //先得到每位数，然后每位数再加上5，再对10求余，最后将所有数字反转，得到一串新数。
        System.out.println("请输入需要加密的数字的个数：");
        Scanner p = new Scanner(System.in);
        int length = p.nextInt();
        int[] num = new int[length];
        for (int i = 0; i < num.length; i++) {
            System.out.println("请输入要加密的第"+(i+1)+"个数字。");
            int number = p.nextInt();
            num[i] = number;
        }
        printArray(num);
        //加密
        for (int i = 0; i < num.length; i++) {
            num[i] = (num[i] + 5) % 10;
        }
        printArray(num);
        for (int i = 0,j = num.length-1; i < j; i++,j--) {
            int tmp = num[j];
            num[j] = num[i];
            num[i] = tmp;
        }
        printArray(num);
    }
    public  static  void printArray(int[] arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(i == arr.length-1 ? arr[i] : arr[i]+",");
        }
        System.out.println("]");
    }
}
